package leetcode;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Ghost
 * Date: 14-6-2
 * Time: 下午9:39
 * To change this template use File | Settings | File Templates.
 */
public class ReverseInt {
    public long reverse(int x) {
        int flag = x>0?1:-1;
        x = Math.abs(x);
        int rst = 0;
        while(x!=0){
            rst = 10*rst + x%10;
            x/=10;
        }
        return flag*rst;
    }
    public static void main(String[]  args){
        ReverseInt reverseInt = new ReverseInt();
        System.out.println(reverseInt.reverse(-123));
    }
}
